home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 37 / Mac Magazin and MacEasy Magazine CD - Issue 37.iso / Software / Entwickler / sonstige / Visual Balloons DR3 / Visual Balloons™ Example / Sources / PP Basic Starter.cp
Text File  |  1997-08-07  |  4KB  |  152 lines

  1. // ===========================================================================
  2. //    PP Basic Starter.cp         ©1994-1997 Metrowerks Inc. All rights reserved.
  3. // ===========================================================================
  4. //
  5. //    This file contains the starter code for a basic PowerPlant application
  6.  
  7. #include "PP Basic Starter.h"
  8.  
  9. #include <LGrowZone.h>
  10. #include <LWindow.h>
  11. #include <PP_Messages.h>
  12. #include <PP_Resources.h>
  13. #include <PPobClasses.h>
  14. #include <UDrawingState.h>
  15. #include <UMemoryMgr.h>
  16. #include <URegistrar.h>
  17. #include <LEditField.h>
  18.  
  19. #include "UVisualBalloons.hpp"
  20.  
  21. // put declarations for resource ids (ResIDTs) here
  22.  
  23. const ResIDT    window_Sample        = 1;    // EXAMPLE
  24.  
  25.  
  26. // ===========================================================================
  27. //        • Main Program
  28. // ===========================================================================
  29.  
  30. void main(void)
  31. {
  32.                                     // Set Debugging options
  33.     SetDebugThrow_(debugAction_Alert);
  34.     SetDebugSignal_(debugAction_Alert);
  35.  
  36.     InitializeHeap(3);                // Initialize Memory Manager
  37.                                     // Parameter is number of Master Pointer
  38.                                     //   blocks to allocate
  39.     
  40.                                     // Initialize standard Toolbox managers
  41.     UQDGlobals::InitializeToolbox(&qd);
  42.     
  43.     new LGrowZone(20000);            // Install a GrowZone function to catch
  44.                                     //    low memory situations.
  45.  
  46.     CPPStarterApp    theApp;            // replace this with your App type
  47.     theApp.Run();
  48. }
  49.  
  50.  
  51. // ---------------------------------------------------------------------------
  52. //        • CPPStarterApp             // replace this with your App type
  53. // ---------------------------------------------------------------------------
  54. //    Constructor
  55.  
  56. CPPStarterApp::CPPStarterApp()
  57. {
  58.     // Register functions to create core PowerPlant classes
  59.     
  60.     RegisterAllPPClasses();
  61.     UVisualBalloons::Initialize (  );
  62.  
  63. }
  64.  
  65.  
  66. // ---------------------------------------------------------------------------
  67. //        • ~CPPStarterApp            // replace this with your App type
  68. // ---------------------------------------------------------------------------
  69. //    Destructor
  70. //
  71.  
  72. CPPStarterApp::~CPPStarterApp()
  73. {
  74. }
  75.  
  76. // ---------------------------------------------------------------------------
  77. //        • StartUp
  78. // ---------------------------------------------------------------------------
  79. //    This function lets you do something when the application starts up
  80. //    without a document. For example, you could issue your own new command.
  81.  
  82. void
  83. CPPStarterApp::StartUp()
  84. {
  85.     ObeyCommand(cmd_New, nil);        // EXAMPLE, create a new window
  86. }
  87.  
  88. // ---------------------------------------------------------------------------
  89. //        • ObeyCommand
  90. // ---------------------------------------------------------------------------
  91. //    Respond to commands
  92.  
  93. Boolean
  94. CPPStarterApp::ObeyCommand(
  95.     CommandT    inCommand,
  96.     void        *ioParam)
  97. {
  98.     Boolean        cmdHandled = true;
  99.  
  100.     switch (inCommand) {
  101.     
  102.         // Deal with command messages (defined in PP_Messages.h).
  103.         // Any that you don't handle will be passed to LApplication
  104.              
  105.         case cmd_New:
  106.                                         // EXAMPLE, create a new window
  107.             LWindow        *theWindow;
  108.             theWindow = LWindow::CreateWindow(window_Sample, this);    
  109.             theWindow->Show();
  110.             break;
  111.  
  112.  
  113.  
  114.         default:
  115.             cmdHandled = LApplication::ObeyCommand(inCommand, ioParam);
  116.             break;
  117.     }
  118.     
  119.     return cmdHandled;
  120. }
  121.  
  122. // ---------------------------------------------------------------------------
  123. //        • FindCommandStatus
  124. // ---------------------------------------------------------------------------
  125. //    This function enables menu commands.
  126. //
  127.  
  128. void
  129. CPPStarterApp::FindCommandStatus(
  130.     CommandT    inCommand,
  131.     Boolean        &outEnabled,
  132.     Boolean        &outUsesMark,
  133.     Char16        &outMark,
  134.     Str255        outName)
  135. {
  136.  
  137.     switch (inCommand) {
  138.     
  139.         // Return menu item status according to command messages.
  140.         // Any that you don't handle will be passed to LApplication
  141.  
  142.         case cmd_New:                    // EXAMPLE
  143.             outEnabled = true;            // enable the New command
  144.             break;
  145.  
  146.         default:
  147.             LApplication::FindCommandStatus(inCommand, outEnabled,
  148.                                                 outUsesMark, outMark, outName);
  149.             break;
  150.     }
  151. }
  152.